package com.pubinfo.passbook.common.service.engine.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pubinfo.passbook.common.entity.TEnginePlaceholderConst;
import com.pubinfo.passbook.common.mapper.TEnginePlaceholderConstMapper;
import com.pubinfo.passbook.common.model.dto.engine.EngineConstParam;
import com.pubinfo.passbook.common.service.engine.EngineComputePlaceHolderConstService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhouch
 * @date 2021/12/16 10:59
 */
@Service
public class EngineComputePlaceHolderConstServiceImpl extends ServiceImpl<TEnginePlaceholderConstMapper, TEnginePlaceholderConst> implements EngineComputePlaceHolderConstService {

    @Override
    public IPage<TEnginePlaceholderConst> page(EngineConstParam param) {
        Page<TEnginePlaceholderConst> pager = param.getPage();
        return new LambdaQueryChainWrapper<>(baseMapper)
                .like(StringUtils.isNotBlank(param.getKeyword()), TEnginePlaceholderConst::getName, param.getKeyword())
                .page(pager);
    }

    @Override
    public List<TEnginePlaceholderConst> likeName(String name) {
        return new LambdaQueryChainWrapper<>(baseMapper)
                .like(StringUtils.isNotBlank(name), TEnginePlaceholderConst::getName, name)
                .list();
    }
}
